<?php
$cs = Yii::app()->clientScript;
$script = <<<JS
$(function(){
    $('body').ajaxSend(function(){
        $.countAjaxRequest = $.countAjaxRequest == undefined ? 0 : $.countAjaxRequest;
        $.countAjaxRequest++;
        var loading = $(this).find('#AjaxLoading');
        loading.show();
    });
    $('body').ajaxComplete(function(e, xhr, settings){
        $.countAjaxRequest--;
        if ($(this).find('#AjaxLoading').length > 0) {
            if ($.countAjaxRequest == 0)
                $(this).find('#AjaxLoading').hide();
        }
    });
});
JS;
$cs->registerScript('ShowAjaxLoading', $script, CClientScript::POS_HEAD);
$popup = Yii::app()->request->getParam('layout', false) == 'popup';
if ($popup)
{
    $script = "
//console.log(jQuery.param.querystring);
jQuery('a').each(function(){
    var selected = jQuery(this);
    var href = selected.attr('href');
    if (/#/.test(href) == false && /javascript:/.test(href) == false && /layout=/.test(href) == false)
    {
        if (/\?/.test(href))
        {
            href += '&';
        }
        else
        {
            href += '?';
        }
        href += 'layout=popup';
        selected.attr('href', href);
    }
});
";
    $cs->registerScript('SubmitForm', $script);
//    $cs->registerCoreScript('bbq');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>
            CPanel | <?php echo Settings::SITE_NAME?>
        </title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="robots" content="noindex, nofollow" />
        <style type="text/css">
        /*<![CDATA[*/
                @import url("<?php echo Yii::app()->theme->baseUrl?>/styles/styles.css?1");
                @import url('<?php echo Yii::app()->theme->baseUrl?>/styles/general.css?1');
                @import url('<?php echo Yii::app()->theme->baseUrl?>/styles/tabmenu.css?1');
                @import url('<?php echo Yii::app()->theme->baseUrl?>/styles/dashboard.css?1');
        /*]]>*/
        </style>
        <link rel="SHORTCUT ICON" href="<?php echo Yii::app()->theme->baseUrl?>/images/favicon.ico" />

        <?php Yii::app()->ClientScript->registerCoreScript('jquery'); ?>
        <script type="text/javascript" src="<?php echo Yii::app()->theme->baseUrl?>/scripts/menudrop.js"></script>
        <script type="text/javascript" src="<?php echo Yii::app()->theme->baseUrl?>/scripts/common.js"></script>
    </head>
    <body<?php echo $popup ? ' class ="popup"' : '';?>>
        <div id="AjaxLoading">
            <img src="<?php echo Yii::app()->theme->baseUrl;?>/images/ajax-loader.gif" />&nbsp; Loading... Please wait...
        </div>
        <?php if ($popup === false):?>
        <div class="Header">
            <div class="logo">
                <a href="<?php echo Yii::app()->createUrl('Admin'); ?>"><img src="<?php echo Yii::app()->theme->baseUrl;?>/images/logo_2.jpg" alt='kodo logo' /><span>Sites Administration</span></a>
            </div>
            <ul class="top-menu">
				<li><a href="<?php echo $this->createUrl('/User/admin/account/updateAdminUser',array('id'=>Yii::app()->user->Id)); ?>">My Account</a><span>|</span></li>
                <li><a href="<?php echo $this->createUrl('/User/admin/account/createAdminUser'); ?>">Create New Administrator</a><span>|</span></li>
                <li><a href="<?php echo $this->createUrl('/Admin/setting'); ?>">Site Configuration</a><span>|</span></li>
				<li class="last"><a target="_blank" href="<?php echo Yii::app()->request->getBaseUrl(true); ?>">View Site</a></li>			
			</ul>
		<div class="logged-in-as">
                <strong>Logged in as:</strong> <?php echo Yii::app()->user->username?>, <a href="<?php echo $this->createUrl('/Core/service/command', array('SID'=>'Core.account.cmdLogout', 'returnUrl'=> Yii::app()->request->getBaseUrl(true).$this->createUrl('/Admin'))); ?>" class="Logout">Logout?</a>
            </div>
        </div>        
        <div class="menuBar">
            <div style="clear: both;"></div>
            <div id="Menu" style="margin-top: 5px;">
                <?php $this->widget('Admin.components.ModuleMenus'); ?>
            </div>
        </div>
        <?php endif;?>
        
        <div class="ContentContainer">
            <?php if ($popup === false):?>
                <?php if (!empty($this->breadcrumbs)):?>
                    <div class="HeaderContainer">
                    <?php $this->widget('zii.widgets.CBreadcrumbs', array(
                        'links'=>$this->breadcrumbs,
                        'htmlOptions'=>array(
                            'id' => 'PageBreadcrumb',
                            'class' => 'Breadcrumb',
                        ),
                        'separator' => "",
                        'homeLink' => CHtml::link('Home',array('/Admin')),
                    )); ?>
                    <?php //$this->widget('Admin.components.GotoMenu');?>
                    <script type="text/javascript">
                    //<![CDATA[
                    //<!--
                    // not in DOM ready, we want this to happen ASAP so the user doesn't see a colour flicker
                    $('#PageBreadcrumb a:first').addClass('Home');
                    $('#PageBreadcrumb span').prev('a').addClass('SecondLast');
                    //-->
                    //]]>
                    </script>
                    </div>
                <?php endif;?>
            <?php endif;?>
            <div class="BodyContainer">
                <?php
                $this->widget('MessageBox');    
                echo $content
                ?>
            </div>
        </div>
        <?php if ($popup === false):?>
        <div class="PageFooter" style="text-align: center;">Copyright &copy; 2011 by Free Technology.<br /> All Rights Reserved.</div>
        <?php endif;?>
    </body>
</html>
